home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / VBASIC / DBAPPMON.ZIP / FORM1.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-08  |  6.6 KB  |  205 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "DBAppMon v1.2 Demo"
  5.    ClientHeight    =   3960
  6.    ClientLeft      =   1350
  7.    ClientTop       =   3000
  8.    ClientWidth     =   7650
  9.    Height          =   4365
  10.    Left            =   1290
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   3960
  13.    ScaleWidth      =   7650
  14.    Top             =   2655
  15.    Width           =   7770
  16.    Begin CommandButton cmdHookF12 
  17.       BackColor       =   &H00C0C0C0&
  18.       Caption         =   "Hook F1&2 + Shift"
  19.       Height          =   375
  20.       Left            =   2100
  21.       TabIndex        =   7
  22.       Top             =   3480
  23.       Width           =   1605
  24.    End
  25.    Begin CommandButton cmdHookF11 
  26.       BackColor       =   &H00C0C0C0&
  27.       Caption         =   "Hook F1&1 + Alt"
  28.       Height          =   375
  29.       Left            =   300
  30.       TabIndex        =   6
  31.       Top             =   3480
  32.       Width           =   1605
  33.    End
  34.    Begin CommandButton cmdHelp 
  35.       BackColor       =   &H00C0C0C0&
  36.       Caption         =   "&?"
  37.       Height          =   372
  38.       Left            =   6660
  39.       TabIndex        =   5
  40.       Top             =   3000
  41.       Width           =   432
  42.    End
  43.    Begin CommandButton cmdNotepad 
  44.       BackColor       =   &H00C0C0C0&
  45.       Caption         =   "&Notepad"
  46.       Height          =   375
  47.       Left            =   5280
  48.       TabIndex        =   4
  49.       Top             =   3000
  50.       Width           =   1215
  51.    End
  52.    Begin CommandButton cmdTaskList 
  53.       BackColor       =   &H00C0C0C0&
  54.       Caption         =   "Show all &tasks"
  55.       Height          =   375
  56.       Left            =   1740
  57.       TabIndex        =   3
  58.       Top             =   3000
  59.       Width           =   1455
  60.    End
  61.    Begin CommandButton cmdModules 
  62.       BackColor       =   &H00C0C0C0&
  63.       Caption         =   "Show all &modules"
  64.       Height          =   375
  65.       Left            =   3360
  66.       TabIndex        =   2
  67.       Top             =   3000
  68.       Width           =   1755
  69.    End
  70.    Begin CommandButton cmdMonitor 
  71.       BackColor       =   &H00C0C0C0&
  72.       Caption         =   "&Start monitor"
  73.       Height          =   375
  74.       Left            =   300
  75.       TabIndex        =   1
  76.       Top             =   3000
  77.       Width           =   1275
  78.    End
  79.    Begin ListBox List1 
  80.       Height          =   2760
  81.       Left            =   60
  82.       TabIndex        =   0
  83.       Top             =   60
  84.       Width           =   7455
  85.    End
  86.    Begin DBAppMon DBAppMon1 
  87.       Left            =   60
  88.       ModuleLookupName=   ""
  89.       Top             =   2820
  90.    End
  91. Option Explicit
  92. Sub AddToBox (x As String)
  93.   If List1.ListCount > 100 Then List1.RemoveItem 0
  94.   List1.AddItem Format$(Now, "HH:MM") + "  " + x
  95. End Sub
  96. Sub cmdHelp_Click ()
  97.   Dim S As String
  98.   S = "DBAppMon is able to monitor application and DLL "
  99.   S = S + "startup and exit and generates VB events when "
  100.   S = S + " this happens. It also has several properties "
  101.   S = S + "for retrieving various information about loaded "
  102.   S = S + "tasks and DLLs. Furthermore, there are properties for "
  103.   S = S + "retrieving version info from executables. (To try this "
  104.   S = S + "feature, double click a line in the list box containing "
  105.   S = S + "a file name.) For more information, please refer to "
  106.   S = S + """DBAPPMON.WRI.""" + Chr$(13) + Chr$(10) + Chr$(13) + Chr$(10)
  107.   S = S + "DBAppMon was written by Dan Bystr
  108. m." + Chr$(13) + Chr$(10)
  109.   S = S + "e-mail: ""dan.bystrom@adb-partner.it-invest.se"""
  110.   MsgBox S, 0, "About DBAppMon"
  111. End Sub
  112. Sub cmdHookF11_Click ()
  113.   If DBAppMon1.HotKey(0) Then
  114.     DBAppMon1.HotKey(0) = 0
  115.     cmdHookF11.Caption = "Hook Alt+F1&1"
  116.   Else
  117.     DBAppMon1.HotKey(2) = &H47A&
  118.     cmdHookF11.Caption = "Unhook Alt+F1&1"
  119.   End If
  120. End Sub
  121. Sub cmdHookF12_Click ()
  122.   If DBAppMon1.HotKey(1) Then
  123.     DBAppMon1.HotKey(1) = 0
  124.     cmdHookF12.Caption = "Hook Ctrl+F1&2"
  125.   Else
  126.     DBAppMon1.HotKey(1) = &HA7B&
  127.     cmdHookF12.Caption = "Unhook Ctrl+F1&2"
  128.   End If
  129. End Sub
  130. Sub cmdModules_Click ()
  131.   Dim S As String
  132.   Dim i As Integer, m As Integer
  133.   List1.Clear
  134.   S = DBAppMon1.AllModules
  135.     m = Val(Mid$(S, i + 1))
  136.     List1.AddItem MyHex(m) + " " + DBAppMon1.ModuleFileName(m) + "  Usage: " & DBAppMon1.ModuleUsage(m)
  137.     i = InStr(i + 1, S, ",")
  138.     If i = 0 Then Exit Do
  139.   Loop
  140. End Sub
  141. Sub cmdMonitor_Click ()
  142.   DBAppMon1.Monitor = Not DBAppMon1.Monitor
  143.   If DBAppMon1.Monitor Then
  144.     cmdMonitor.Caption = "&Stop monitor"
  145.     List1.Clear
  146.   Else
  147.     cmdMonitor.Caption = "&Start monitor"
  148.   End If
  149. End Sub
  150. Sub cmdNotepad_Click ()
  151.   List1.AddItem "Returned from Shell function: " & MyHex(Shell("notepad.exe"))
  152. End Sub
  153. Sub cmdTaskList_Click ()
  154.   Dim S As String
  155.   Dim i As Integer, t As Integer
  156.   List1.Clear
  157.   S = DBAppMon1.AllTasks
  158.     t = Val(Mid$(S, i + 1))
  159.     List1.AddItem MyHex(t) + " " + DBAppMon1.TaskFileName(t) + "  Parent: " & MyHex(DBAppMon1.TaskParent(t))
  160.     i = InStr(i + 1, S, ",")
  161.     If i = 0 Then Exit Do
  162.   Loop
  163. End Sub
  164. Sub DBAppMon1_AppExit (hTask As Integer, nExitCode As Integer)
  165.   AddToBox "AppExit code= " & nExitCode & " (" & MyHex(hTask) & ")"
  166. End Sub
  167. Sub DBAppMon1_AppStart (hTask As Integer)
  168.   AddToBox "AppStart (" & MyHex(hTask) & ") hInst: " & MyHex(DBAppMon1.TaskInstance(hTask)) & " " & DBAppMon1.TaskFileName(hTask) & "  Parent: " & MyHex(DBAppMon1.TaskParent(hTask))
  169. End Sub
  170. Sub DBAppMon1_DLLExit (hModule As Integer)
  171.   AddToBox "DLLExit (" & MyHex(hModule) & ")"
  172. End Sub
  173. Sub DBAppMon1_DLLStart (hModule As Integer)
  174.   AddToBox "DLLStart (" & MyHex(hModule) & ") " & DBAppMon1.ModuleFileName(hModule)
  175. End Sub
  176. Sub DBAppMon1_HotKey (KeyCode As Integer, KeyInfo As Integer)
  177.   AddToBox "HotKey: " & Hex$(KeyCode) & " " & Hex$(KeyInfo)
  178. End Sub
  179. Sub Form_Load ()
  180.   List1.AddItem "This application was started from " & DBAppMon1.TaskFileName(DBAppMon1.TaskParent(DBAppMon1.MyTask))
  181. End Sub
  182. Sub List1_DblClick ()
  183.   Dim FN As String, i As Integer
  184.   FN = List1.List(List1.ListIndex)
  185.   i = InStr(FN, ":\")
  186.   If i < 2 Then
  187.     MsgBox "This line doesn't contain a file name!", 48
  188.     Exit Sub
  189.   End If
  190.   FN = Mid$(FN, i - 1)
  191.   i = InStr(FN, " ")
  192.   If i Then FN = Left$(FN, i - 1)
  193.   On Error Resume Next
  194.   DBAppMon1.VerReadInfo = FN
  195.   If Err Then
  196.     MsgBox "The file """ + FN + """ doesn't contain any version info!", 48
  197.     Exit Sub
  198.   End If
  199.   Form2.Show 1
  200.   DBAppMon1.VerReadInfo = ""
  201. End Sub
  202. Function MyHex (ByVal h As Integer) As String
  203.   MyHex = "$" + Right$("000" + Hex$(h), 4)
  204. End Function
  205.